import 'package:kxy_flutter_app/model/login_result.dart';

class Auth {
  static Auth _instance;
  static Auth get instance {
    if (_instance == null) {
      _instance = new Auth();
    }
    return _instance;
  }

  bool _isAuth = false;
  get isAuth => _isAuth ?? '';

  String _secret;
  get secret => _secret ?? '';

  String _token;
  get token => _token ?? '';

  String _tenantId;
  get tenantId => _tenantId ?? '';

  String _userId;
  get userId => _userId ?? '';

  authorize(LoginResult loginResult) {
    this._token = loginResult.token;
    this._tenantId = loginResult.tenantId;
    this._userId = loginResult.userId;
    this._secret = loginResult.secret;
    this._isAuth = true;
  }

  unauthorize() {
    this._token = null;
    this._tenantId = null;
    this._userId = null;
    this._secret = null;
    this._isAuth = false;
  }
}
